/**
 * 记忆化递归的方式
**/
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 51;
const int MODE = 1000000007;
int a[MAXN][MAXN];
int n, m, k; 

int cache[MAXN][MAXN][13][13];

int dfs(int r, int c, int _max, int rest)
{
    // cout << r << " --- " << c << endl;
    if(r < 0 || r >= n || c < 0 || c >= m || rest < 0) return 0;
    
    if(r == n - 1 && c == m - 1 && rest == 0) return 1;

    // 查缓存
    if(cache[r][c][_max + 1][rest] != -1) return cache[r][c][_max + 1][rest];

    int ans = 0;

    // 选选择
    if(a[r][c] > _max && rest > 0)
    {
        if(r == n - 1 && c == m - 1 && rest == 1) return 1;
        
        ans = (ans + dfs(r + 1, c, a[r][c], rest - 1)) % MODE;
        ans = (ans + dfs(r, c + 1, a[r][c], rest - 1)) % MODE;
    }

    // 不能选 或 不选 合并为同一个情况
    ans = (ans + dfs(r + 1, c, _max, rest)) % MODE;
    ans = (ans + dfs(r,c + 1, _max, rest)) % MODE;
    return cache[r][c][_max + 1][rest] = ans;
}

int main()
{
#ifdef LOCAL
    freopen("PREV-28.in", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    memset(cache, -1, sizeof(cache));
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            cin >> a[i][j];
    int ret = dfs(0, 0, -1, k);
    cout << ret << endl;
    return 0;
}